package com.yksj.healthtalk.entity;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

public class ChargeRecordEntity {

	/**
	 * 交易时间
	 */
	private String chargeTime;
	/**
	 * 交易号
	 */
	private String transactionNum;
	/**
	 * 支付方式
	 */
	private String chargeWayType;
	/**
	 * 支付数量
	 */
	private String chargeNum;
	
	private String id;//订单的id
	
	

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getChargeTime() {
		return chargeTime;
	}

	public void setChargeTime(String chargeTime) {
		this.chargeTime = chargeTime;
	}

	public String getTransactionNum() {
		return transactionNum;
	}

	public void setTransactionNum(String transactionNum) {
		this.transactionNum = transactionNum;
	}

	public String getChargeWay() {
		return chargeWayType;
	}

	public void setChargeWay(String chargeWay) {
		if("1".equals(chargeWay))
		this.chargeWayType = "支付宝";
		else{
			this.chargeWayType = "未知";
		}
	}

	public String getChargeNum() {
		return chargeNum;
	}

	public void setChargeNum(String chargeNum) {
		this.chargeNum = chargeNum;
	}

	@Override
	public String toString() {
		return "ChargeRecordEntity [chargeTime=" + chargeTime
				+ ", transactionNum=" + transactionNum + ", chargeWay="
				+ chargeWayType + ", chargeNum=" + chargeNum + "]";
	}
	
	/**
	 * 解析充值历史的,返回集合
	 * @param json
	 * @return
	 */
	public static List<ChargeRecordEntity> parseToListRecord(JSONArray obj){
		List<ChargeRecordEntity> entities=null;
		try {
			entities=new ArrayList<ChargeRecordEntity>();
			for (int i = 0; i < obj.length(); i++) {
				ChargeRecordEntity entity=new ChargeRecordEntity();
				JSONObject json=(JSONObject)obj.get(i);
				entity.setChargeTime(json.getString("CREATE_TIME"));
				entity.setTransactionNum(json.getString("ORDER_CODE"));
				entity.setId(json.getString("ORDER_ID"));
				entity.setChargeWay(json.getString("ORDER_TYPE"));
				entity.setChargeNum(json.getString("PAY_NUM"));
				entities.add(entity);
			}
			return entities;
		} catch (Exception e) {
			return entities;
		}
	}
}
